/**
 * Created by xiaowuge on 2015/7/14.
 */
$(function(){
    $('body').delegate('.deleteOilPro','click',function(){
        var self = $(this);
        swal({   title: "您确定吗?",
                text: "您将进行删除操作！",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "是的，删除",
                cancelButtonText: "放弃",
                closeOnConfirm: true
            },
            function (isConfirm) {
                if (isConfirm) {
                    self.closest('.col-xs-4').remove();
                }

            });
    });

    $('#addOilBtn').on('click',function(){
        var self = $(this);
        self.closest('div').before('<div class="col-xs-4 addOilList">' +
        '<div class="panel panel-default">' +
        '<div class="panel-heading clearfix">' +
        '<a href="javascript:void(0);" class="pull-right text-left text-danger deleteOilPro">' +
        '<i class="glyphicon glyphicon-trash "></i>' +
        '</a>' +
        '</div>' +
        '<div class="panel-body">' +
        '<form>' +
        '<div class="form-group">' +
        '<label for="proName" class="control-label">品名:</label>' +
        '<input type="text" class="form-control oilNameInput" placeholder="品名">' +
        '</div>' +
        '<div class="form-group">' +
        '<label for="proPrice" class="control-label">价格:</label>' +
        '<div class="input-group"><input  value="" type="text"  placeholder="价格" class="form-control oilPriceInput"/><div class="input-group-addon">元</div></div>' +
        '' +
        '</div>' +
        '</form>' +
        '</div>' +
        '</div>' +
        '</div>');
    });
});